package com.gitee.wsl.mathematics.vector.vec

import com.gitee.wsl.io.dataproxy.DataProxy
import com.gitee.wsl.io.dataproxy.asProxy
import com.gitee.wsl.mathematics.vector.MutableVectorD


class MutableVec(override val proxy: DataProxy<Double>): Vec(proxy=proxy), MutableVectorD<Vec> {
    constructor(list: List<Double> = emptyList()):this(list.asProxy())
    constructor(vararg list:Number):this(list.map { it.toDouble() })

    override var length: Double
        get() = sqrt(squaredLength)
        set(value) {
            val newVec = normalized * value
            this.proxy.updateIndexed{ i, _ ->newVec.proxy[i]}
        }
}